package com.itheima.algorithm.binarytree;

/**
 * @author: TylerZhong
 * @description:
 */
public class E04Leetcode101 {

    public boolean isSymmetric(TreeNode node) {
        return check(node.left, node.right);
    }

    private boolean check(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        if (left == null || right == null) {
            return false;
        }
        if (left.val != right.val) {
            return false;
        }
        return check(left.left, right.right) && check(left.right, right.left);
    }

    public static void main(String[] args) {

    }
}
